package pages;

import org.openqa.selenium.WebElement;
import utils.Log4Test;

/**
 * Created by gzhovnuvaty on 7/17/14.
 */
public class LoginPage extends GeneralPage {




    public DashboardPage submitLoginButton(){
        Log4Test.info("Submit 'Login' button");
        elementIsLocated(getLocator("loginButton")).click();
        return new DashboardPage();
    }

    public SummaryPage submitLoginButtonForRegularUser() {
        Log4Test.info("Click 'Login' button and enter as regular user");
        elementIsLocated(getLocator("loginButton")).click();
        return new SummaryPage();
    }

    public LoginPage typeEmail(String email){
        Log4Test.info("Enter 'Email'");
        elementIsLocated(getLocator("emailField")).sendKeys(email);
        return this;
    }


    public LoginPage typePassword(String password){
        Log4Test.info("Enter 'Password'");
        elementIsLocated(getLocator("passwordField")).sendKeys(password);
        return this;
    }


    public DashboardPage loginAs(String email, String password){
        typeEmail(email);
        typePassword(password);
        return submitLoginButton();
    }

    public SummaryPage loginAsRegularUser(String email, String password) {
        typeEmail(email);
        typePassword(password);
        return submitLoginButtonForRegularUser();
    }

    public WebElement forgotPasswordLink(){
        Log4Test.info("Find 'Forgot password' link");
        return elementIsLocated(getLocator("forgotPasswordLink"));
    }



}
